package com.SweetWhite.UserManagement.model.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.SweetWhite.UserManagement.model.bean.Hero_User;
import com.SweetWhite.UserManagement.model.service.SelectService;



@Controller
public class SelectByPageController {
	@Autowired
	private SelectService service; 
	@RequestMapping("getByPage")
	public String selectByPage(Integer page, HttpSession session) {
		List<Hero_User> list=new ArrayList<Hero_User>();
		System.out.println("页数是："+page);
		int pagef= (page-1)*10;
		System.out.println("参数是："+pagef);
		list = service.selectByPage(pagef);
		session.setAttribute("list", list);
		return "redirect:getByPage.jsp";
	}
	@RequestMapping("getPageNum")
	public String  getPageNum(HttpSession session) throws IOException {
		List<Hero_User> list =new ArrayList<>();
		list=service.getHero_User();
		List<Integer> allPages=new ArrayList<>();
		int allEntries=list.size();
		for(Integer  i=1;i<=allEntries/10+1;i++) {
			allPages.add(i);
		}
			session.setAttribute("b", true);
			session.setAttribute("allPages", allPages);
			return "redirect:getByPage.jsp";
	}
	@RequestMapping("setBoo")
	public String setBoo(HttpSession session) {
		session.setAttribute("b", false);
		return "redirect:getByPage.jsp";
		
	}
}
